package com.qyl.deguru.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.qyl.deguru.dao.AddressDao;
import com.qyl.deguru.dao.BaseDao;
import com.qyl.deguru.dto.Address;
import com.qyl.deguru.mapper.AddressMapper;
import com.qyl.deguru.mapper.OrderMapper;

public class AddressDaoImple extends BaseDao implements AddressDao {

	@Override
	public List<Address> getAddressByUser_id(int aid) {
		SqlSession session=getSqlSession();
		AddressMapper addMapper=session.getMapper(AddressMapper.class);
		List<Address> add=addMapper.getAddressByUser_id(aid);
		closeSqlSession();
		return add;
	}

	@Override
	public void delAddressById(int did) {
		SqlSession session=getSqlSession();
		OrderMapper orderMapper=session.getMapper(OrderMapper.class);
		orderMapper.delOrderByAddress_id(did);
		AddressMapper addMapper=session.getMapper(AddressMapper.class);
		addMapper.delAddressById(did);
		session.commit();
		closeSqlSession();
		
	}

}
